package com.smartwasser.yunhtgl.apphtgl.presenter;

import com.smartwasser.yunhtgl.apphtgl.bean.SPGreat4Bean;
import com.smartwasser.yunhtgl.apphtgl.network.RetrofitApi;
import com.smartwasser.yunhtgl.apphtgl.network.Retrofits;
import com.smartwasser.yunhtgl.apphtgl.view.SPGreat4View;
import com.smartwasser.yunhtgl.apphtgl.utils.Logger;

import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class SPGreat4PresenterImpl implements SPGreat4Presenter {
    private SPGreat4View spGreat4View;

    public SPGreat4PresenterImpl(SPGreat4View spGreat4View) {
        this.spGreat4View = spGreat4View;
    }


    @Override
    public void getType1Sp1Great4(String JSESSIONID, String id) {
        Retrofits.getInstance().createReq(RetrofitApi.class).getType1Sp1Great4(JSESSIONID, id)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<SPGreat4Bean>() {
            @Override
            public void onCompleted() {
            }

            @Override
            public void onError(Throwable e) {
                spGreat4View.error();
                Logger.e("onError");
            }

            @Override
            public void onNext(final SPGreat4Bean spGreat4Bean) {
                spGreat4View.success(spGreat4Bean);
                Logger.e("onNext");
            }
        });
    }
}